define(function(require) {
	var _common = require('common/main');
	var _send = _common.sendRequest;
	function init() {
		_bind_query_user();
	}
	
	function _bind_query_user()
	{
		var _param = {};
		$('#user_query').click(_query_user);
		_send("zone/userQueryZone.ajax", _param, _query_zone_render);
	}
	
	function _query_zone_render(data)
	{
		if(data!=null)
		{
			var _len = data.length;
			var _html = '<option value="-1">全部</option>';
			for (var i = 0; i < _len; i++) {
				var _item = data[i];
				_html += '<option value="';
				_html += _item.zoneId;
				_html += '">';
				_html += _item.zoneName;
				_html += '</option>';
			}
			$('#user_zone_id').html(_html);
		}
	}
	
	
	function _query_user()
	{
		var _userid = $('#user_userid').val();
		var _cardid = $('#user_cardid').val();
		var _cellphone = $('#user_cellphone').val();
		var _zoneid = $('#user_zone_id option:selected').attr("value");
		var _registerF = $('#user_registertimeF').val();
		var _registerT = $('#user_registertimeT').val();
		var _lastbuyF = $('#user_lastbuytimeF').val();
		var _lastbuyT = $('#user_lastbuytimeT').val();

		var _consumestart = $('#user_consumestart').val();
		var _consumeend = $('#user_consumeend').val();
		var _balancestart = $('#user_balancestart').val();
		var _balanceend = $('#user_balanceend').val();
		var _state = $('#user_state option:selected').attr("value");

		var _param = _common.stringify({
			userid : _userid,
			cardid : _cardid,
			cellphone : _cellphone,
			zoneid : _zoneid,
			registerF : _registerF,
			lastbuyF : _lastbuyF,
			registerT : _registerT,
			lastbuyT : _lastbuyT,
			consumestart : _consumestart,
			consumeend : _consumeend,
			balancestart : _balancestart,
			balanceend : _balanceend,
			state : _state
		});
		_send("user/queryUser.ajax", _param, _query_user_render);
	}
	
	
	function _query_user_render(data) {
		var _len = data.length;
		$('#user_search').html('<span style="color:red"><font><b>共有'+_len+'条搜索结果</font></b></span><br/>');
		var _html = '';
		for (var i = 0; i < _len; i++) {
			var _item = data[i];
			_html += '<tr class="success">';
			_html += '<td nowrap="nowrap">';
			_html += _item.userId;
			_html += '</td>';
			_html += '<td nowrap="nowrap">';
			_html += _item.cardId;
			_html += '</td>';
			_html += '<td nowrap="nowrap">';
			_html += _item.userName;
			_html += '</td>';
			_html += '<td nowrap="nowrap">';
			_html += _item.cellPhone;
			_html += '</td>';
			_html += '<td nowrap="nowrap">';
			_html += _item.zoneName;
			_html += '</td>';
			_html += '<td nowrap="nowrap">';
			_html += _item.registerTime;
			_html += '</td>';
			_html += '<td nowrap="nowrap">';
			_html += _item.lastBuyTime;
			_html += '</td>';
			_html += '<td nowrap="nowrap">';
			_html += _item.consumeStr;
			_html += '</td>';
			_html += '<td nowrap="nowrap">';
			_html += _item.balanceStr;
			_html += '</td>';
			_html += '<td nowrap="nowrap">';
			_html += _item.stateDesc;
			_html += '</td>';
			_html += '</tr>';
		}
		
		$('#user_list').html(_html);
	}
	return {
		init : init
	};
});